package com.xinqi.modules.stats.score.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.modules.stats.score.dto.req.CourseTotalScoreContentSonClassDTO;
import com.xinqi.modules.stats.score.dto.req.CourseTotalScoreContentSonSetDTO;
import com.xinqi.modules.stats.score.dto.rsp.CourseTotalScoreContentSonResultDTO;
import com.xinqi.modules.stats.score.service.CourseTotalScoreContentSonService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 总成绩子成绩项配置WEB控制层
 *
 * @author: system
 * @date: 2023/03/26
 */
@Tag(name = "总成绩课程子成绩项目配置WEB端", description = "总成绩课程子成绩项目配置WEB端")
@RestController
@RequestMapping("/web/total-score-content-son")
@RequiredArgsConstructor
public class CourseTotalScoreContentSonWebController {

    private final CourseTotalScoreContentSonService courseTotalScoreContentSonService;

    /**
     * 获取子成绩项
     * @param dto 初始化参数
     * @return
     */
    @GetMapping("/list")
    public R<List<CourseTotalScoreContentSonResultDTO>> list(CourseTotalScoreContentSonClassDTO dto) {
        return R.data(courseTotalScoreContentSonService.findTotalScoreContentSon(dto));
    }

    /**
     * 设置子成绩项
     * @param dto 初始化参数
     * @return
     */
    @PostMapping("/set")
    public R<String> set(@RequestBody CourseTotalScoreContentSonSetDTO dto) {
        if (courseTotalScoreContentSonService.setTotalScoreContentSon(dto)) {
            return R.ok("操作成功");
        } else {
            return R.fail("操作失败");
        }
    }

    /**
     * 获取子成绩项
     * @param dto 初始化参数
     * @return
     */
    @GetMapping("/setting/list")
    public R<List<CourseTotalScoreContentSonResultDTO>> settingList(CourseTotalScoreContentSonClassDTO dto) {
        return R.data(courseTotalScoreContentSonService.findExistTotalScoreContentSon(dto));
    }

}
